package com.hzjy.manage.controller;


import com.hzjy.api.beans.HzjyServiceCharge;
import com.hzjy.api.service.impl.HzjyServiceChargeServiceImpl;
import com.hzjy.common.core.domain.AjaxResult;
import com.hzjy.common.core.domain.model.LoginUser;
import com.hzjy.common.utils.ServletUtils;
import com.hzjy.framework.web.service.TokenService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api("费用信息")
@RestController
@RequestMapping("/manage/hzjy_service_carge")
public class hzjyServiceChargeController {

    @Autowired
    private HzjyServiceChargeServiceImpl hzjyServiceChargeService;

    @Autowired
    private TokenService tokenService;

    @ApiOperation("费用信息")
    @PreAuthorize("@ss.hasPermi('manage:hzjy_service_carge:list')")
    @PostMapping("/findServiceCharge")
    public AjaxResult findServiceCharge(HzjyServiceCharge hzjyServiceCharge){
        List<HzjyServiceCharge> hzjyServiceCharges = hzjyServiceChargeService.selectHzjyServiceChargeList(hzjyServiceCharge);
        return AjaxResult.success(200,"成功",hzjyServiceCharges);
    }


    @ApiOperation("修改费用信息")
    @PreAuthorize("@ss.hasPermi('manage:hzjy_service_carge:update')")
    @PostMapping("/updateServiceCharge")
    public AjaxResult updateServiceCharge(@RequestBody HzjyServiceCharge hzjyServiceCharge){
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        hzjyServiceCharge.setUpdateUser(loginUser.getUser().getUserId().toString());
        hzjyServiceChargeService.updateHzjyServiceCharge(hzjyServiceCharge);
        return AjaxResult.success();
    }
}
